<template>
  <view>
 <view class="system_view">
 <view class="system_title">系统</view>
 <view class="system_list">
   <o-cell border card> 
       <o-cell-item title='设备信息' @tap="gotoDeviceDetail" arrow/>
       <o-cell-item title='内部参数设置' @tap="gotoRoom" v-if="isAdmin" arrow/>
       <o-cell-item title="恢复出厂设置" @tap="gotolay" v-if="isAdmin" arrow />
       <o-cell-item title="固件升级" @tap="goupgrade" v-if="isAdmin" arrow />
       <o-cell-item title="我上传的图片" @tap="goMyUploadImg" arrow />
   </o-cell>
 </view>
 </view>
  <navtabar :selected="index"></navtabar>
  </view>
</template>

<script>
 import {
    deviceControl
  } from "@/api/system/equiment/equipment.js"
 import navtabar from '../components/proofing-tabbar/index.vue';
  export default {
    components: {
      navtabar
    },
    data() {
      return {
        index:2,
        Reset: 13,
        isAdmin:uni.getStorageSync("isAdmin"),
        equipmentNo:uni.getStorageSync("equipmentNo"), //uni.getStorageSync("equipmentNo"),
        equipmentTypeId:uni.getStorageSync("equipmentTypeId"), //uni.getStorageSync("equipmentTypeId"),
      }
    },
    methods: {
      //跳转设备信息界面
      gotoDeviceDetail(){
        uni.navigateTo({
          url:'../deviceInfo/index'
        })
      },
      //跳转内部参数界面
      gotoRoom(){
        uni.navigateTo({
          url:'../parameterSet/index'
        })
      },
      //点击恢复出厂设置
      gotolay: async function () {
          const thant=this
          uni.showModal({
            title: '温馨提示',
            content: '确定恢复出厂设备吗？',
            success: async function (res) {
              if (res.confirm) {
                const cmdData=[{
                   "cmd":thant.Reset,  
                   "value":0
                 }]
                const res = await deviceControl(thant.equipmentTypeId,thant.equipmentNo,JSON.stringify(cmdData));
               if(res.code=200){
                thant.$modal.msgSuccess("操作成功");
               }else{
                  thant.$modal.msgError("下发失败");
               }
              }
            }
          })
        },
        //点击固件升级跳转界面
        goupgrade(){
          uni.navigateTo({
            url:'../upgrade/index'
          })
        },
        //跳转我上传图片界面查看我上传的图片
        goMyUploadImg(){
          uni.navigateTo({
            url:'../myuploadimg/index'
          })
        }
    }
  }
</script>

<style>
.system_title{
  font-size:48rpx;font-weight: bold;margin-left: 30rpx;margin-top: 30rpx;
}
.system_list{
  margin-top: 135rpx;font-weight: bold;
}
</style>
